import { Injectable, Inject } from '@nestjs/common';
import { InjectRepository } from '@nestjs/typeorm';
import { Repository } from 'typeorm';
import { User } from './login.entity';
import { Cache } from 'cache-manager';
import { CACHE_MANAGER } from '@nestjs/cache-manager';

@Injectable()
export class loginService {
  constructor(
    @InjectRepository(User)
    private userRepository: Repository<User>,
  ) {}

  async findAll(): Promise<User[]> {
    return this.userRepository.find();
  }
  async findLogin(data): Promise<User[]> {
    const users = this.userRepository.find({
      where: { passWord: data.password, userName: data.username },
    });
    return users;
  }
  async userRegister(data): Promise<User[]> {
    const users = this.userRepository.create(data);
    return await this.userRepository.save(users);
  }
}
